
pub fn convert_base(num_str: &str, to_base: u32) -> String {
    // TODO: 这里写逻辑
    // todo!()

    let parts: Vec<&str> = num_str.split('(').collect();
    if parts.len() != 2 {
        return "Invalid input".to_string();
    }

    // 获取数字和进制
    let number=parts[0];
    let from_base_str=parts[1].trim_end_matches(')');

    // 将原始进制字符串解析为 u32 类型
    let from_base:u32 = match from_base_str.parse() {
        Ok(base) => base,
        Err(_) => return "Invalid base".to_string(),
    };

    // 将数字从原始进制转换为十进制
    let decimal_number=match u32::from_str_radix(number, from_base) {
        Ok(val) => val,
        Err(_) => return "Invalid number".to_string(),
    };

    // 将十进制数字转换为目标进制
    if to_base < 2 || to_base > 36 {
        return "Invalid target base".to_string();
    }

    let mut res=String::new();
    let mut value=decimal_number;

    while value > 0 {
        let remainder = (value % to_base) as u8;
        let digit = if remainder < 10 {
            (b'0' + remainder) as char
        } else {
            (b'a' + remainder - 10) as char
        };
        res.insert(0, digit);
        value /= to_base;
    }

    // 
    if res.is_empty() {
        res.push('0');
    }

    res
    
}
